﻿using Bigway.Common.Models.DbModels;
using Bigway.Common.Utils;
using SqlSugar;

namespace Benefactor.Models.DbModels;

public class Benefit: DeletableEntity
{
    [SugarColumn(IsNullable = false)]
    public string BenefitsCardId { get; set; }

    [SugarColumn(IsNullable = false)]
    public string ProductId { get; set; }

    private string? _imageUrl;
    [SugarColumn(IsNullable = false)]
    public string ImageUrl
    {
        get => UrlUtils.GetAbsoluteUrl(Statics.AppConfig.FileApiBaseUrl, _imageUrl);
        set => _imageUrl = UrlUtils.GetRelativeUrl(value);
    }

    public int Count { get; set; }

    [Navigate(NavigateType.OneToOne, nameof(ProductId))]
    public Product? Product { get; set; }
}